@using OrchardCore.Themes.Services
@using OrchardCore.Entities
@using OrchardCore.ResourceManagement.TagHelpers
@inject DarkModeService DarkModeService
@{
    var adminSettings = Site.As<AdminSettings>();
    var darkMode = await DarkModeService.IsDarkModeAsync();

    // Branding is pre-rendered to allow resource injection
    var brandingHtml = await DisplayAsync(await New.AdminBranding());
}
<!DOCTYPE html>
<html lang="@Orchard.CultureName()" dir="@Orchard.CultureDir()" data-tenant="@DarkModeService.CurrentTenant" data-theme="@DarkModeService.CurrentTheme" data-darkmode="@adminSettings.DisplayDarkMode">
<head>
    <title>@RenderTitleSegments(Site.SiteName, "before")</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <!-- Bootstrap CSS -->
    <style media="all" asp-name="admin" version="1"></style>
    <style asp-name="material-icons" version="1"></style>

    <script asp-name="font-awesome" at="Head" version="6"></script>
    <script asp-name="font-awesome-v4-shims" at="Head" version="6"></script>
    <script asp-name="js-cookie" at="Foot"></script>
    <script asp-name="admin" version="1" at="Foot"></script>
    <resources type="Header" />

    <!-- This script can't wait till the footer -->
    <script asp-name="admin-head" version="1"></script>
    @await RenderSectionAsync("HeadMeta", required: false)
</head>
<body class="preload">
    <div class="ta-wrapper">
        <div class="ta-navbar-top navbar-expand-lg bg-primary">
            <div class="d-flex w-100">
                @brandingHtml
                <div class="flex-grow-1">
                    @if (adminSettings.DisplayTitlesInTopbar)
                    {
                        @await RenderSectionAsync("Title", required: false)
                    }
                </div>
                <div class="d-flex align-items-center">
                    @await RenderSectionAsync("NavbarTop", required: false)
                    @if (adminSettings.DisplayDarkMode)
                    {
                        <a id="btn-darkmode" class="me-3" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@(darkMode ? T["Light mode"] : T["Dark mode"])" role="button">
                            @if (darkMode)
                            {
                                <i class="fas fa-sun" aria-hidden="true"></i>
                                <span class="d-none">@T["Light mode"]</span>
                            }
                            else
                            {
                                <i class="fas fa-moon" aria-hidden="true"></i>
                                <span class="d-none">@T["Dark mode"]</span>
                            }
                        </a>
                    }
                    <a href="@Url.Content("~/")" class="me-3" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom" title="@T["Visit Site"]" role="button">
                        <i class="fa fa-fw fa-external-link" aria-hidden="true"></i>
                    </a>
                    @await DisplayAsync(await New.UserMenu())
                </div>
            </div>
        </div>

        <div id="ta-left-sidebar" class="d-flex flex-column justify-content-between align-items-stretch">
            @await RenderSectionAsync("Navigation", required: false)
            <div class="footer">
                <button type="button" class="leftbar-compactor" title="@T["Collapse / expand menu"]">
                    <span class="d-none">@T["Collapse / expand menu"]</span>
                </button>
            </div>
        </div>

        <div class="ta-content">
            @await RenderSectionAsync("Header", required: false)
            @await RenderSectionAsync("Messages", required: false)
            @await RenderSectionAsync("Breadcrumbs", required: false)
            @if (!adminSettings.DisplayTitlesInTopbar)
            {
                @await RenderSectionAsync("Title", required: false)
            }
            @await RenderBodyAsync()
        </div>

        @await RenderSectionAsync("Footer", required: false)

    </div>
    <div id="confirmRemoveModalMetadata" data-title="@T["Delete"]" data-message="@T["Are you sure you want to remove this element?"]" data-ok-text="@T["Ok"]" data-cancel-text="@T["Cancel"]" data-ok-class="btn-danger" data-cancel-class="btn-secondary"></div>
    <resources type="Footer" />
</body>
</html>
